<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Purchase/index')}">列表</a></li>
        <li><a href="{:url('Purchase/add')}">添加</a></li>
    </ul>
    <form class=" well form-inline margin-top-20" method="get" action="{:url('Purchase/index')}">
        姓名:
        <input type="text" class="form-control" name="key_name" style="width:150px;"
               value="" placeholder="">

        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('Purchase/index')}">清空</a>
    </form>


    <table class="table table-hover table-bordered" >
        <thead>
        <tr>
            <th>ID</th>
            <th>合同号</th>
            <th>订货日期</th>
            <th>合同金额</th>
            <th>发票金额</th>
            <th>是否完结</th>
            <th>图片附件</th>
            <th>文件附件</th>
            <th>备注</th>
            <th width="150">操作</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="lists['data']" item="vo">
            <tr>
                <td>
                    {$vo['id']}
                </td>
                <td>
                    {$vo['ht_num']}
                </td>
                <td>
                    {:date('Y-m-d H:i',$vo['order_time'])}
                </td>
                <td>
                    {$vo['invoice']}
                </td>
                <td>
                    {$vo['ht_price']}
                </td>
                <td>
                    <if condition="$vo['is_end']==1" >
                      是
                          <else/>
                  否
                    </if>

                </td>
                <td>
                    <button onclick="detail({$vo.id},'image_enclosure')" type="button" class="btn btn-info">查看</button>
                </td>
                <td>
                    <button onclick="detail({$vo.id},'file_enclosure')" type="button" class="btn btn-info">查看</button>
                </td>
                <td>
                    {$vo['remark']}
                </td>
                <td>
                    <a class="btn btn-xs btn-primary" href="{:url('Purchase/edit',['id'=>$vo['id']])}">编辑</a>
                    <a class="btn btn-xs btn-primary" href="{:url('Purchasesub/index',['id'=>$vo['id']])}">查看子项</a>
                    <a class="btn btn-xs btn-danger js-ajax-delete"
                       href="{:url('Purchase/del',['id'=>$vo['id']])}">删除</a>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>
<script src="/static/js/admin.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script>
    function see(obj) {
        layer.open({
            content: $(obj).text().trim()
        });
    }

    function detail(id, field) {
        $.ajax({
            url: '{:url('Purchase / field
        ')}?id=' + id + '&field=' + field,
            type
    :
        'get',
            success(res)
        {
            if (res.code == 1) {
                let tpl = '';
                for (const item of res.data) {
                    tpl += `<p>地址：<input value="${item}" readonly class="form-control" style="width:80%;display: inline-block;" type="text">&nbsp;<a target="_blank" href="{$domain}${item}" class="btn btn-success">跳转</a></p>`;
                }
                layer.open({
                    area: ['60%', '100%'],
                    content: tpl
                });
            } else {
                layer.msg('查看失败');
            }
        }
    })
        ;
    }
</script>
</body>
</html>
</body>
</html>
